<template>
	<view class="wrap" :style='{"padding-top": statusBarHeight+"px"}'>
		<!-- <view class="fixed-top" :style='{"padding-top": statusBarHeight+"px"}'> -->
		<view class="fixed-top">
			<view class="acea-row row-middle row-between search-header">
				<image src="" mode="aspectFill" @click="goback"></image>
				<view class="acea-row row-middle search-box">
					<view class="search-ipt">
						<text class="iconfont icon-xiazai5"></text>
						<input class="uni-input"  placeholder="搜索"  v-model="projectKey" @confirm="toSearch"/>
					</view>
				</view>
			</view>
		</view>
		<view class="list">
			<view class="content"  v-for="(item,index) in projectList" :key="item.id" >
				<view class="top acea-row row-between row-middle" @click="toPage('/pages/details/project/project?id='+item.id)">
					<view class="left acea-row row-middle  ">
						<image :src="item.thumbnail" mode="aspectFill"></image>
						<text class="enter_limit">{{item.name}}</text>
					</view>
					<view class="right">
						<image src="" mode=""></image>
					</view>
				</view>
				<view class="bottom acea-row row-between row-middle" @click="toPage('/pages/details/project/project?id='+item.id)">
					
					<text :class="item.auditStatus == 1?'':'equie'">{{auditStatusDic[item.auditStatus]}}</text>
					<!-- <image src="../../static/images/gift.png" mode=""></image> -->
					<view class="contents acea-row row-middle row-between ">
						<image  :src="item.thumbnail" mode=""></image>
						<view class="contents">
							<view class="line limit">
								地址： {{item.address || ''}}
							</view>
							<view class="line">
								开发商： {{item.developerName || '不详'}}
							</view>
							<view class="line">
								开工/交付时间： {{item.commencementDate || '0'}}
							</view>
						</view>
						
					</view>
				</view>
				<view class="area acea-row row-around row-middle">
					<view class="col_38 acea-row row-column text_c"><text>{{item.floorage || '0'}}m²</text><text
							class="col_A6 mt_28">总面积数</text></view>
					<view class="col_38 acea-row row-column text_c"><text>{{item.residentialUnits || '0'}}</text><text
							class="col_A6 mt_28">住宅套数</text></view>
					<view class="col_38 acea-row row-column text_c"><text>{{item.residentialPrice || '0'}}</text><text
							class="col_A6 mt_28">住宅均价</text></view>
					<view class="col_38 acea-row row-column text_c"><text>{{item.commercialPrice || '0'}}</text><text
							class="col_A6 mt_28">商业均价</text></view>
				</view>
				<view class="line_bottom"></view>
				<view class="btns acea-row row-right">
<!-- 					<view class="btn">
						出租
					</view>
					<view class="btn">
						出售
					</view> -->
					<view class="btn" @click="toEdit(item.id)">
						编辑
					</view>
					<view class="btn"  @click="toDelete(item.id)">
						删除
					</view>
				</view>
			</view>
		</view>
		<view class='loadingicon acea-row row-center row-middle'>
			<text class='loading iconfont icon-jiazai' :hidden='loading'></text>{{loadTitle}}
		</view>
		<!-- 底部按钮 -->
		<view class="publish_btn" @click="publish">新增项目</view>
	</view>
</template>

<script>
	import {getProjectList,delProject} from '@/api/centerModule/index.js'
	import {
		toPage
	} from '@/filters/commFilter.js'
	var app = getApp();
	export default {
		data() {
			return {
				statusBarHeight: 0,
				city: '武汉',
				shareInfo: {},
				page: 1,
				limit: 8,
				projectList:[],
				auditStatusDic:{
					'0':'待审',
					'1':'成功',
					'2':'驳回'
				},
				projectKey:'',
				loading:true,
				loadTitle:''
			}
		},
		created() {
			this.getOnListData();
		},
		onLoad() {
			// #ifdef MP || APP-PLUS
			// let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
			// this.statusBarHeight = (Number(menuButtonInfo.bottom) + 5);
			// #endif
			// #ifdef H5
			this.statusBarHeight = 20;
			// #endif
		},
		onShow() {
			// if (!this.isLogin) {
			// 	toLogin();
			// } else {
			// 	this.getUserInfo();
			// }
		},
		onHide() {},
		methods: {
			toPage,
			publish() {
				let that = this;
				wx.navigateTo({
					url: '/pages/releases/project/project',
					events:{
						upList:function(){
							that.getOnListData();
						}
					}
				})
			},
			goback() {
				// #ifdef H5
				return history.back();
				// #endif
				// #ifndef H5
				return uni.navigateBack({
					delta: 1,
				})
				// #endif
			},
			getOnListData(){
				this.loading = false;
				getProjectList({
					page:this.page,
					limit: this.limit,
					name: this.projectKey
				}).then(res=>{
					this.loading = true;
					if(this.page == 1){
						this.projectList = res.data.list;
						if(this.projectList.length<=0){
							this.loadTitle= '暂无数据'
						}
					}else{
						this.projectList=this.projectList.concat(res.data.list);
						if(res.data.list.length<=0){
							this.loadTitle= '已加载所有'
						}
					}
				})
			},
			toEdit(id){
				let that = this;
				uni.navigateTo({
					url:'/pages/releases/project/project?id='+ id,
					events:{
						upList:function(){
							that.page = 1;
							that.getOnListData();
						}
					}
				})
			},
			toDelete(id){
				let that = this;
				uni.showModal({
				    title: '提示',
				    content: '你确定要删除吗',
				    success: function (res) {
				        if (res.confirm) {
				        	delProject(id).then(res=>{
								that.page = 1;
				        		that.getOnListData();
				        	})
				        } else if (res.cancel) {
				        	console.log('取消');
				        }
				    }
				});
			},
			toSearch(){
				this.page = 1;
				this.getOnListData();
				
			}
		},
		onReachBottom() {
			this.page++;
			this.getOnListData();
		}
	}
</script>

<style lang="scss" scoped>
	.wrap {
		padding-bottom: 160rpx;
	}
	.col_38 {
		color: #383838;
	}

	.col_A6 {
		color: #A6A6A6;
	}

	.mt_28 {
		margin-top: 28rpx;
	}

	.text_c {
		text-align: center;
	}

	.sys-head {
		width: 100%;
		background: #EE212D;
	}

	.fixed-top {
		width: 100%;
		background: #EE212D;
		position: fixed;
		top: 0;
		left: 0;
		height: 122rpx;
		z-index: 999;
		background: linear-gradient(90deg, #EE212D 0%, #EE212D 100%);
	}

	.search-header {
		width: 100%;
		padding: 26rpx;
		background: #EE212D;

		image {
			width: 28rpx;
			height: 32rpx;
			margin-right: 34rpx;
		}

		.search-map {
			font-size: 22rpx;
			font-weight: 400;
			color: rgba(255, 255, 255, 1);
			text-align: center;

			image {
				width: 40rpx;
				height: 36rpx;
			}
		}
	}

	.search-box {
		// width: 586rpx;
		flex: 1;
		height: 70rpx;
		opacity: 1;
		border-radius: 36rpx;
		background: rgba(255, 255, 255, 1);
		padding: 12rpx 32rpx;

		.search-ipt {
			display: flex;
			align-items: center;
			color: rgba(166, 166, 166, 1);

			text {
				padding: 0 16rpx 0 0rpx;
			}
		}
	}

	.list {
		margin: 154rpx 28rpx 0;
	}

	.content {
		padding: 30rpx 26rpx;
		margin-top: 32rpx;
		background-color: #fff;
		border-radius: 10rpx;

		.top {
			height: 56rpx;
			padding-bottom: 14rpx;
			border-bottom: 2rpx solid #EEEEEE;

			.left {
				image {
					width: 32rpx;
					height: 32rpx;
					margin-right: 12rpx;
				}
			}

			.right {
				image {
					width: 18rpx;
					height: 28rpx;
				}
			}
		}

		.bottom {
			position: relative;
			margin: 16rpx 0;

			image {
				height: 144rpx;
				width: 170rpx;
				border-radius: 10rpx;
				margin-right: 22rpx;
			}

			.contents {
				flex: 1;
				color: #808080;
			}

			.line {
				word-break: break-all;
				line-height: 44rpx;
				font-size: 24rpx;
				color: #808080;
			}

			.equie {
				position: absolute;
				right: 0;
				top: 4rpx;
				color: #EE212D;
				font-size: 24rpx;
			}

			.limit {
				max-width: 350rpx;
			}
		}
	}

	.area {
		margin: 16rpx 0 32rpx;
		background-color: #F7F7F7;
		height: 144rpx;
		border-radius: 4rpx;
		box-sizing: border-box;
		padding: 16rpx 0;
	}

	.line_bottom {
		margin: 0 0 32rpx;
		height: 3rpx;
		background-color: #EEEEEE;
		overflow: hidden;
	}

	.btn {
		width: 100rpx;
		height: 44rpx;
		line-height: 40rpx;
		font-size: 24rpx;
		color: #808080;
		box-sizing: border-box;
		text-align: center;
		border-radius: 4px;
		border: 2rpx solid #E5E5E5;

		&:not(:last-child) {
			margin-right: 24rpx;
		}
	}

	.publish_btn {
		position: fixed;
		left: 50%;
		transform: translateX(-199rpx);
		bottom: 48rpx;
		background-color: #EE212D;
		color: #fff;
		width: 398rpx;
		height: 98rpx;
		line-height: 98rpx;
		color: #fff;
		text-align: center;
		box-shadow: 0px 3px 8px 0px #F50F1E;
		border-radius: 100rpx;
		z-index: 999
	}
    
	.enter_limit {
		word-break: break-all;
		max-width: 380rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
</style>
